[code-reusability] Reuse shared bytes-to-MiB conversion - #264
Merged
Pedro Henrique Penna (ppenna) merged 1 commit intoSep 30, 2026
Merged
Pedro Henrique Penna (ppenna) merged 1 commit into
Pedro Henrique Penna (ppenna) merged 1 commit into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Pedro Henrique Penna (ppenna)
September 29, 2026 21:49
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The refactor preserves the conversion and has no unresolved findings.
Review effort: Balanced
Findings: None
What changed in this PR
This PR moves the bytes-to-MiB helper into nvx_tools.common so benchmark and lifecycle reporting share the same conversion.
Changes:
- Reuse the shared helper for benchmark RSS reporting.
- Use it for lifecycle metrics and OpenVMM diagnostics.
| File | Description |
|---|---|
scripts/nvx_tools/performance.py |
Uses the shared helper for lifecycle conversions. |
scripts/nvx_tools/common.py |
Defines the shared helper. |
scripts/nvx_tools/benchmark.py |
Imports the helper instead of defining it locally. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Pedro Henrique Penna (ppenna)
marked this pull request as ready for review
September 30, 2026 05:40
Pedro Henrique Penna (ppenna)
deleted the
code-reusability/shared-bytes-to-mib-313e30b848df9b39
branch
September 30, 2026 15:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Move the existing internal
benchmark.bytes_to_mib()helper tonvx_tools.commonand reuse it for lifecycle result collection and diagnostics inperformance.py.The helper's existing callers are the ten benchmark RSS formatting and summary paths in
scripts/nvx_tools/benchmark.py. The second call site is lifecycle performance conversion inread_lifecycle_data()andappend_openvmm_diagnostics(), which repeatedvalue / (1024 * 1024)throughBYTES_PER_MIB.For every
intorfloatthese sites pass,bytes_to_mib(value)returns the identical float division result. The surrounding unit selection, formatting precision, metrics, messages, and errors are unchanged. The existing focused lifecycle collection test verifies both converted metric values and rendered MiB diagnostics; the helper's existing benchmark callers remain covered by the full suite.Evidence
Open issues, open pull requests, active workflow changes, and pull-request history were checked for
bytes_to_mib,BYTES_PER_MIB, and the bytes-to-MiB concern. No active, rejected, or duplicate proposal covers this reuse. Active workflow PRs concern snapshot tiers, TCP console cleanup, and usage documentation, and do not overlap these functions or files. Prior merged reusability PRs cover different helpers.Patch
scripts/nvx_tools/common.pyscripts/nvx_tools/benchmark.pyscripts/nvx_tools/performance.pyValidation
python -m unittest scripts.test_performance.PerformanceTests.test_collects_openvmm_json_and_appends_diagnostics -v- passed (1 test)python -m unittest scripts/test_performance.py scripts/test_nvx_tools.py scripts/test_microvm_tests.py scripts/test_development_release.py -v- passed (362 tests, 6 skipped)python scripts/test_adversarial.py -v- passed (55 tests)python .github/skills/nvx-host-connect/scripts/test_hosts.py -v- passed (4 tests)python -m compileall -q scripts- passedpython -m ruff check scripts- passedpython -m pyright --pythonplatform Linux- passedpython -m pyright --pythonplatform Windows- passedpython -m ruff format --check scripts- passedpython scripts/nvx.py --help- passedpython scripts/nvx.py test-openvmm-unit --help- passedpython scripts/nvx.py test-openvmm --help- passedpython scripts/nvx.py test-microvm --help- passedpython scripts/nvx.py test-adversarial --help- passedpython scripts/nvx.py benchmark --help- passedgit diff --check- passedNo dependency, public API/CLI/ABI, gitlink, or OpenVMM change was made. Hardware, private-submodule, and OpenVMM checks were not applicable and were not run.